<?php

include("global.php");

$pagetitle=" - Administration - Backup";
$links=" > Administration > Backup";

include ("header.php");

include ("admin_header.php");

if($userloggedinarray[15]!=="administrator"){
   echo template('noticenocpaccess');
}else{

 if(!$backup&&!$restore&&!$delete){
 unset($tplcontent);
 
 $tplcontent['addnew'].="admin_backup.php?backup=1";

 $backuparray=listdirs("backups");
 for($n=0;$n<count($backuparray);$n++){
 	unset($tplcontent2);
  $tplcontent2['date'].=date($dateformat,$backuparray[$n]+$timeoffsetseconds);
  $tplcontent2['restore'].="admin_backup.php?restore=$backuparray[$n]";
  $tplcontent2['delete'].="admin_backup.php?delete=$backuparray[$n]";
  $tplcontent['backuplist'].=template('adminbackuprow',$tplcontent2);
 }
 
 echo template('adminbackupview',$tplcontent);
 }
 
 if($backup==1){
 $time=time();
 createdir("backups");
 createdir("backups/$time");
  
  copydir($maindatadir,"backups/$time/data");
  
   echo template('noticebackupfinished',$tplcontent);
 }
 
 if($restore){
  deletedir($maindatadir);
  copydir("backups/$restore/data",$maindatadir);
  
   echo template('noticebackuprestored');
 }
 
 if($delete){
  
   deletedir("backups/$delete");

   echo template('noticebackupdeleted');
 }
 
}
include("admin_footer.php");

include("footer.php");

?>
